package com.cat.dataStructure03;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/range-product-queries-of-powers/
 * @create 2025/11/17 08:46
 * @since JDK17
 */

public class Solution74 {
    public int[] productQueries(int n, int[][] queries) {
        int m = queries.length, k = Integer.bitCount(n);
        long N = ((int) 1e9) + 7;
        int[] arr = new int[m], nums = new int[k];
        System.out.println(n & -n);
        for (int i = 0, j = n & -n; i < k; i++, j = n & -n) {
            nums[i] = j;
            n ^= j;
        }
        for (int i = 0; i < m; i++) {
            arr[i] = 1;
            for (int l = queries[i][0], r = queries[i][1]; l <= r; l++) {
                arr[i] = (int) ((long)arr[i] * nums[l] % N);
            }
        }

        return arr;
    }
}
